project(LandGraphicsOgl)

file(GLOB INCS inc/*.h)
file(GLOB HEADERS src/*.h)
file(GLOB SOURCES src/*.c)
add_library(land_ogl
    ${INCS}
    ${SOURCES}
    ${HEADERS}
    )

target_include_directories(land_ogl PRIVATE src)
target_include_directories(land_ogl PUBLIC inc)
target_link_libraries(land_ogl PUBLIC land_graphics)
if(BUILD_SHARED_LIBS)
    target_compile_definitions(land_ogl PUBLIC LAND_OGL_EXPORTS)
endif()

find_package (OpenGL REQUIRED)

add_definitions (-DGLEW_NO_GLU)
target_compile_definitions(land_ogl PUBLIC GLEW_NO_GLU)
target_link_libraries (land_ogl PUBLIC ${OPENGL_LIBRARIES})

if(MSVC)
	if(BUILD_SHARED_LIBS)
		target_compile_definitions (land_ogl PRIVATE "GLEW_BUILD;VC_EXTRALEAN")
	else()
		target_compile_definitions (land_ogl PRIVATE "GLEW_STATIC;VC_EXTRALEAN")
	endif()
	target_compile_options (land_ogl PRIVATE -GS-)
elseif (WIN32 AND ((CMAKE_C_COMPILER_ID MATCHES "GNU") OR (CMAKE_C_COMPILER_ID MATCHES "Clang")))
  # remove stdlib dependency on windows with GCC and Clang (for similar reasons
  # as to MSVC - to allow it to be used with any Windows compiler)
  target_compile_options (land_ogl PRIVATE -fno-builtin -fno-stack-protector)
  target_link_libraries (land_ogl LINK_PRIVATE -nostdlib)
endif ()